<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>接单员管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		
		var factorId='';
		//设置厂家接单员
		function administrators(id){
			factorId=id;
			var href="${ctx}/jiujiu/jiuManufactor/memberList?factorId="+factorId+"&type=2";
			top.$.jBox.open('iframe:'+href,'选择用户',$(top.document).width()-800,$(top.document).height()-120,{
				buttons:{"关闭":true},
				loaded:function(h){
					$(".jbox-content", top.document).css("overflow-y","hidden");
					$(".nav,.form-actions,[class=btn]", h.find("iframe").contents()).hide();
					$("body", h.find("iframe").contents()).css("margin","10px");
				}
			});
			
			//定时刷新
			   window.setInterval(function(){ 
				 if(factorId!=''){
						$.getJSON("${ctx}/jiujiu/jiuReceiver/getReceiverList",{factorId:factorId}, function(data){
							var str = '';
		                    var list=data.result;
		                    var len = list.length;
		                    if (len > 0) {
		                        $.each(list, function (i, item) {
										str+='<tr><td>'+
											'<img src="'+item.headimgurl+'" style="width:40px"/>'+
											 '</td>'+
											'<td>'+item.memberName+'</td><td>'+
											'<a class="btn btn-danger" href="${ctx}/jiujiu/jiuReceiver/delete?id='+item.id+'&manufactorId='+item.manufactorId+'">删除</a>'+
											'</td></tr>'; 
		                          });
		                    } 
		                    
		                    $('#zhu').html(str);
		                });
					}
			}, 1000);
			
			return false;
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/jiujiu/jiuReceiver?&manufactorId=${jiuReceiver.manufactorId}">接单员列表</a></li>
		<shiro:hasPermission name="jiujiu:jiuReceiver:edit"><li><a href="javascript:administrators(${jiuReceiver.manufactorId})">接单员添加</a></li></shiro:hasPermission>
	</ul>
	<form:form id="searchForm" modelAttribute="jiuReceiver" action="${ctx}/jiujiu/jiuReceiver/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<input id="manufactorId" name="manufactorId" type="hidden" value="${jiuReceiver.manufactorId}"/>
		<label>名称 ：</label><form:input path="name" htmlEscape="false" maxlength="50" class="input-medium"/>
		&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
	</form:form>
	<tags:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered ">
		<thead><tr>
		<th>头像</th>
		<th>名称</th>
		<shiro:hasPermission name="jiujiu:jiuReceiver:edit"><th>操作</th></shiro:hasPermission></tr></thead>
		<tbody id="zhu">
		<c:forEach items="${page.list}" var="jiuReceiver">
			<tr>
				<td><img src="${jiuReceiver.headimgurl}" style="width:40px;height:40px"  /></td>
				<td>${jiuReceiver.memberName}</td>
				<shiro:hasPermission name="jiujiu:jiuReceiver:edit"><td>
    				<a class="btn btn-success" href="${ctx}/jiujiu/jiuReceiver/form?id=${jiuReceiver.id}">修改</a>
					<a class="btn btn-danger" href="${ctx}/jiujiu/jiuReceiver/delete?id=${jiuReceiver.id}&manufactorId=${jiuReceiver.manufactorId}" onclick="return confirmx('确认要删除该接单员吗？', this.href)">删除</a>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>
